package com.qian.apiserver.service;

import com.qian.apiserver.entity.GmRatio;
import com.qian.apiserver.dao.RatioDao;
import java.math.BigDecimal;
import com.qian.apiserver.model.Ratio;
import org.springframework.beans.factory.annotation.Autowired;
import com.yaowk.service.common.BaseRepository;
import com.qian.apiserver.service.IRatioService;
import java.lang.String;
import com.yaowk.service.common.BaseServiceImpl;
import java.lang.Integer;

public abstract class RatioServiceBase extends BaseServiceImpl<Ratio, GmRatio, Integer> implements IRatioService {

	@Autowired
	private RatioDao dao;

	@Override protected RatioDao getDao() {
	return dao;
	}

	@Override
	protected Ratio entity2model(GmRatio entity) {
		Ratio model = null;
		if(isNotEmpty(entity)){
			model = new Ratio();
			model.setId(entity.getId());
			model.setType(entity.getType());
			model.setRate(entity.getRate());
		}
		return model;
	}

	@Override
	protected GmRatio model2Entity(Ratio model) {
		GmRatio entity = null;
		if(isNotEmpty(model)){
			entity = new GmRatio();
			entity.setId(model.getId());
			entity.setType(model.getType());
			entity.setRate(model.getRate());
		}
		return entity;
	}

	@Override
	protected GmRatio updateParams(Ratio model) {
		GmRatio entity = dao.findOne(model.getId());
		if(isNotEmpty(model.getType()))
			entity.setType(model.getType());
		if(isNotEmpty(model.getRate()))
			entity.setRate(model.getRate());
		return entity;
	}


}